<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float:left" v-if="model=='shop'">
      <router-link to="./bo_form/">
        <el-button
          type="primary"
          icon="el-icon-plus"
          style="margin-left:0px"
        >添加</el-button>
      </router-link>
      <el-button
    plain
    style="margin-left:5px"
    @click="open">
    预警信息
  </el-button>
    </div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%;margin-top:50px"
      >
        <el-table-column align="center" prop="id" label="序号" width="70" :fixed="isMobile()?'left':undefined"/>
        <el-table-column align="center" prop="card_name" label="记录人员" />
        <el-table-column align="center" prop="mobile" label="手机号" />
        <el-table-column align="center" prop="subscribe_time" label="商机时间" />
      
        <el-table-column
          align="center"
          prop="telephone"
          width="240"
          label="操作"
        >
          <template slot-scope="scope">
            <router-link :to="'./bo_form/' + scope.row.id">
              <el-button size="small" type="primary" icon="el-icon-edit" />
            </router-link>
            <el-button
              type="danger"
              size="small"
              icon="el-icon-delete"
              @click="onDel(scope.row.id)"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from '@/components/control/control.vue'

export default {
  components: { control },
  name:'activity_index',
   computed: {
       model(){
         return this.$store.state.user.model;
       }
    },
  data() {
    return {
      config: [
        { type: 'text', placeholder: '请输入活动昵称', field: 'title', val: '' }
      ],
      value: '',
      searchWhere: {
        title: '',
        type:2
      },
      tableData: [],
      type_arr: [],
      total: 0,
      current_page: 1,
      per_page: 14
    }
  },
  activated(){
    if(this.$getUpdate()){
      this.onSearch()
    }
  },
  created() {
    this.onSearch()
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
   open() {
        this.$notify({
          title: '预警信息',
          message: this.yujing_text,
          offset: 100
        });
      },
    onSearch() {
      const form = {}
      form.page = this.current_page
      form.map = this.searchWhere
      this.get(this.model+'/Registration/index', form, 'POST').then(e => {
        this.yujing_text = e.yujing_text
        this.tableData = e.list.data
        this.per_page = e.list.per_page
        this.total = e.list.total
        this.type_arr = e.type_arr
        this.current_page = e.list.current_page
      })
    },
    // 添加
    onAdd() {},
    // 编辑
    onEdit(id) {
      console.log(id)
    },
    // 修改状态
    change_status(id, field, val) {
      this.update(id, val, field, 'Activity').then(e => {
        e ? this.onSearch() : ''
      })
    },
    // 删除
    onDel(id) {
      this.$msg_confirm().then(e => {
        if (e) {
          this.get(this.model+'/Registration/del?id=' + id, this.form, 'POST').then(e => {
            this.onSearch()
          })
        }
      })
    }
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
